<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据类型判断</title>
</head>
<body>
    <script>
        //1. typeof  只能区分 基本数据类型  不能精准区分引用数据类型  [] {} null
        //2. instanceof 它可以精准区分 引用数据类型 ，又区分不了基本数据类型
        //3. Object.prototype.toString.call(变量)

        // console.log(Object.prototype.toString.call(1));//[object Number]
        // console.log(Object.prototype.toString.call('1'));//[object String]
        // console.log(Object.prototype.toString.call(true));//[object Boolean]
        // console.log(Object.prototype.toString.call(null));//[object Null]
        // console.log(Object.prototype.toString.call(undefined));//[object Undefined]
        // console.log(Object.prototype.toString.call([]));//[object Array]
        // console.log(Object.prototype.toString.call({}));//[object Object]
        // console.log(Object.prototype.toString.call(Symbol('123')));//[object Symbol]

        function getType(param){
            return Object.prototype.toString.call(param).slice(8, -1);
        }

        let a = '1';
        if(getType(a) === 'Number'){
            console.log('是一个数组')
        }
    </script>
</body>
</html>